package com.opencloud.ywt.provider.controller;
import cn.hutool.core.date.DateUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.opencloud.common.model.PageParams;
import com.opencloud.common.model.ResultBody;
import com.opencloud.common.utils.DateUtils;
import com.opencloud.ywt.client.model.entity.*;
import com.opencloud.ywt.provider.service.BhyfBdbService;
import com.opencloud.ywt.provider.service.BhyfStudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

/**
 * 贝多邦
 * @author yeyong
 */
@Slf4j
@RestController
@Api(value = "贝多邦", tags = "贝多邦")
public class BhyfBdbController {
    @Autowired
    private BhyfBdbService bhyfBdbService;
    @Autowired
    private BhyfStudentService bhyfStudentService;

    /**
     * 获取评价规则
     * @param gradenum
     * @param angletype
     * @return
     */
    @ApiOperation(value = "获取评价规则", notes = "获取评价规则")
    @GetMapping("/bdb/rulelist")
    public ResultBody<List<BhyfBdbRule>> getBhyfBdbRule(
            @RequestParam(required = false) int gradenum,
            @RequestParam(required = false) int angletype
    )
    {
        return ResultBody.ok().data(bhyfBdbService.findRuleList(gradenum,angletype));
    }

    /**
     * 获取评价列表
     * @param map
     * @return
     */
    @ApiOperation(value = "获取评价列表", notes = "获取评价列表")
    @GetMapping("/bdb/levelchecklist")
    public ResultBody<List<BhyfBdbLevelcheck>> getBhyfBdbLevelcheckList(
            @RequestParam(required = false) Map map
    )
    {
        return ResultBody.ok().data(bhyfBdbService.findLevelCheckList(new PageParams(map)));
    }


    /**
     * 新增评价
     * @param gid
     * @param classid
     * @param gradenum
     * @param personid
     * @param name
     * @param classname
     * @param angletype
     * @param checkmonth
     * @param checklevel
     * @param ruletype
     * @param ruletypename
     * @return
     */
    @ApiOperation(value = "新增评价", notes = "新增评价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gid", value = "园ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "classid", value = "班级ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "gradenum", value = "年级ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "personid", value = "学生ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "name", value = "学生名称", required = true, paramType = "form"),
            @ApiImplicitParam(name = "classname", value = "班级名称", required = true, paramType = "form"),
            @ApiImplicitParam(name = "angletype", value = "类型", required = true, paramType = "form"),
            @ApiImplicitParam(name = "checkmonth", value = "月份", required = true, paramType = "form"),
            @ApiImplicitParam(name = "checklevel", value = "评分", required = true, paramType = "form"),
            @ApiImplicitParam(name = "ruletype", value = "评分对象类型", required = true, paramType = "form"),
            @ApiImplicitParam(name = "ruletypename", value = "评分对象名称", required = true, paramType = "form")
    })
    @PostMapping("/bdb/addlevelcheck")
    public ResultBody<BhyfBdbLevelcheck> addBhyfBdbLevelCheck
    (
            @RequestParam(name = "gid",required = true) Integer gid,
            @RequestParam(name = "classid",required = true) Integer classid,
            @RequestParam(name = "gradenum",required = true) Integer gradenum,
            @RequestParam(name = "personid",required = true) Integer personid,
            @RequestParam(name = "name",required = true) String name,
            @RequestParam(name = "classname",required = true) String  classname,
            @RequestParam(name = "angletype",required = true) Integer angletype,
            @RequestParam(name = "checkmonth",required = true) String checkmonth,
            @RequestParam(name = "checklevel",required = true) Integer checklevel,
            @RequestParam(name = "ruletype",required = true) Integer ruletype,
            @RequestParam(name = "ruletypename",required = true) String ruletypename
    )
    {
        BhyfBdbLevelcheck entiy = bhyfBdbService.isExistCheckLevel(personid,ruletype,checkmonth,angletype);
        if(entiy==null)
        {
            BhyfBdbLevelcheck model = new BhyfBdbLevelcheck();
            model.setGid(gid);
            model.setAngletype(angletype);
            model.setCheckmonth(checkmonth);
            model.setClassid(classid);
            model.setClassname(classname);
            model.setCreatetime(new Date());
            model.setGradenum(gradenum);
            model.setName(name);
            model.setChecklevel(checklevel);
            model.setRuletype(ruletype);
            model.setUpdatetime(new Date());
            model.setPersonid(personid);
            model.setRuletypename(ruletypename);
            entiy = bhyfBdbService.addLevelcheck(model);
        }else{
            entiy.setChecklevel(checklevel);
            entiy = bhyfBdbService.updateLevelcheck(entiy);
        }
        return ResultBody.ok().data(entiy);
    }

    /**
     * 更新评价
     * @param id
     * @param checklevel
     * @return
     */
    @ApiOperation(value = "更新评价", notes = "更新评价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "评价ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "checklevel", value = "评分", required = true, paramType = "form")
    })
    @PostMapping("/bdb/updatelevelcheck")
    public ResultBody<BhyfBdbLevelcheck> updateBhyfBdbLevelCheck
            (
                    @RequestParam(name = "id",required = true) Integer id,
                    @RequestParam(name = "checklevel",required = true) Integer checklevel
            )
    {
        BhyfBdbLevelcheck entiy =bhyfBdbService.findLevelCheckById(id);
        if(entiy!=null && entiy.getId()>0) {
            entiy.setChecklevel(checklevel);
            bhyfBdbService.updateLevelcheck(entiy);
        }
        return ResultBody.ok().data(entiy);
    }

    /**
     * 新增规则
     * @param gradenum
     * @param angletype
     * @param rulename
     * @param ruleobject
     * @param ruletype
     * @param ruletypename
     * @return
     */
    @ApiOperation(value = "新增规则", notes = "新增规则")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gradenum", value = "年级", required = true, paramType = "form"),
            @ApiImplicitParam(name = "angletype", value = "区角类型", required = true, paramType = "form"),
            @ApiImplicitParam(name = "rulename", value = "规则名称", required = true, paramType = "form"),
            @ApiImplicitParam(name = "ruleobject", value = "规则目标", required = true, paramType = "form"),
            @ApiImplicitParam(name = "ruletype", value = "评分类型代码", required = true, paramType = "form"),
            @ApiImplicitParam(name = "ruletypename", value = "评分类型名称", required = true, paramType = "form")
    })
    @PostMapping("/bdb/addrule")
    public ResultBody<BhyfBdbRule> addBhyfBdbRule
            (
                    @RequestParam(name = "gradenum",required = true) Integer gradenum,
                    @RequestParam(name = "angletype",required = true) Integer angletype,
                    @RequestParam(name = "rulename",required = true) String rulename,
                    @RequestParam(name = "ruleobject",required = true) String ruleobject,
                    @RequestParam(name = "ruletype",required = true) Integer ruletype,
                    @RequestParam(name = "ruletypename",required = true) String  ruletypename
            )
    {
        BhyfBdbRule entiy = new BhyfBdbRule();
        entiy.setAngletype(angletype);
        entiy.setCreatetime(new Date());
        entiy.setGid(0);
        entiy.setGradenum(gradenum);
        entiy.setRulelevel(4);
        entiy.setRulename(rulename);
        entiy.setRuleobject(ruleobject);
        entiy.setUpdatetime(new Date());
        entiy.setRuletype(ruletype);
        entiy.setRuletypename(ruletypename);
        entiy = bhyfBdbService.addBhyfBdbRule(entiy);
        return ResultBody.ok().data(entiy);
    }


    /**
     * 获取目标列表
     * @param angletype
     * @param ruletype
     * @return
     */
    @ApiOperation(value = "获取目标列表", notes = "获取目标列表")
    @GetMapping("/bdb/objectlist")
    public ResultBody<List<BhyfBdbRuleObject>> getBhyfBdbObjectList(
            @RequestParam(required = true) Integer angletype,
            @RequestParam(required = true) Integer ruletype
    )
    {
        return ResultBody.ok().data(bhyfBdbService.findRuleObjectList(angletype,ruletype));
    }


    /**
     * 获取学习品质评价列表
     * @param map
     * @return
     */
    @ApiOperation(value = "获取学习品质评价列表", notes = "获取学习品质评价列表")
    @GetMapping("/bdb/learnchecklist")
    public ResultBody<List<BhyfBdbLearnCheck>> getBhyfBdbLearncheckList(
            @RequestParam(required = false) Map map
    )
    {
        return ResultBody.ok().data(bhyfBdbService.findLearnCheckList(new PageParams(map)));
    }


    /**
     * 新增学习品质评价
     * @param gid
     * @param classid
     * @param gradenum
     * @param personid
     * @param name
     * @param classname
     * @param checkmonth
     * @param jjzd
     * @param hqxq
     * @param rzzz
     * @param bpkn
     * @param tjcs
     * @param xxcz
     * @param fszj
     * @return
     */
    @ApiOperation(value = "新增学习品质评价", notes = "新增学习品质评价")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "gid", value = "园ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "classid", value = "班级ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "gradenum", value = "年级ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "personid", value = "学生ID", required = true, paramType = "form"),
            @ApiImplicitParam(name = "name", value = "学生名称", required = true, paramType = "form"),
            @ApiImplicitParam(name = "classname", value = "班级名称", required = true, paramType = "form"),
            @ApiImplicitParam(name = "checkmonth", value = "月份", required = true, paramType = "form"),
            @ApiImplicitParam(name = "jjzd", value = "积极主动", required = true, paramType = "form"),
            @ApiImplicitParam(name = "hqxq", value = "好奇兴趣", required = true, paramType = "form"),
            @ApiImplicitParam(name = "rzzz", value = "认真专注", required = true, paramType = "form"),
            @ApiImplicitParam(name = "bpkn", value = "不怕困难", required = true, paramType = "form"),
            @ApiImplicitParam(name = "tjcs", value = "探究尝试", required = true, paramType = "form"),
            @ApiImplicitParam(name = "xxcz", value = "想象创造", required = true, paramType = "form"),
            @ApiImplicitParam(name = "fszj", value = "反思总结", required = true, paramType = "form"),
    })
    @PostMapping("/bdb/addlearncheck")
    public ResultBody<BhyfBdbLearnCheck> addBhyfBdbLearnCheck
            (
                    @RequestParam(name = "gid",required = true) Integer gid,
                    @RequestParam(name = "classid",required = true) Integer classid,
                    @RequestParam(name = "gradenum",required = true) Integer gradenum,
                    @RequestParam(name = "personid",required = true) Integer personid,
                    @RequestParam(name = "name",required = true) String name,
                    @RequestParam(name = "classname",required = true) String  classname,
                    @RequestParam(name = "checkmonth",required = true) String checkmonth,
                    @RequestParam(name = "jjzd",required = true) Integer jjzd,
                    @RequestParam(name = "hqxq",required = true) Integer hqxq,
                    @RequestParam(name = "rzzz",required = true) Integer rzzz,
                    @RequestParam(name = "bpkn",required = true) Integer bpkn,
                    @RequestParam(name = "tjcs",required = true) Integer tjcs,
                    @RequestParam(name = "xxcz",required = true) Integer xxcz,
                    @RequestParam(name = "fszj",required = true) Integer fszj
            )
    {
        BhyfBdbLearnCheck entiy = bhyfBdbService.isExistLearnCheck(personid,checkmonth);
        if(entiy==null)
        {
            BhyfBdbLearnCheck model = new BhyfBdbLearnCheck();
            model.setGid(gid);
            model.setCheckmonth(checkmonth);
            model.setClassid(classid);
            model.setClassname(classname);
            model.setCreatetime(new Date());
            model.setGradenum(gradenum);
            model.setName(name);
            model.setUpdatetime(new Date());
            model.setPersonid(personid);
            model.setBpkn(bpkn);
            model.setFszj(fszj);
            model.setHqxq(hqxq);
            model.setJjzd(jjzd);
            model.setRzzz(rzzz);
            model.setTjcs(tjcs);
            model.setXxcz(xxcz);
            entiy = bhyfBdbService.addLearncheck(model);
        }else{
            entiy.setBpkn(bpkn);
            entiy.setFszj(fszj);
            entiy.setHqxq(hqxq);
            entiy.setJjzd(jjzd);
            entiy.setRzzz(rzzz);
            entiy.setTjcs(tjcs);
            entiy.setXxcz(xxcz);
            entiy = bhyfBdbService.updateLearncheck(entiy);
        }
        return ResultBody.ok().data(entiy);
    }


    /**
     * 更新学习品质评价
     * @param id
     * @param jjzd
     * @param hqxq
     * @param rzzz
     * @param bpkn
     * @param tjcs
     * @param xxcz
     * @param fszj
     * @return
     */
    @ApiOperation(value = "更新学习品质评价", notes = "更新学习品质评价")
    @PostMapping("/bdb/updatelearncheck")
    public ResultBody<BhyfBdbLearnCheck> updateBhyfBdbLearnCheck
            (
                    @RequestParam(name = "id",required = true) Integer id,
                    @RequestParam(name = "jjzd",required = true) Integer jjzd,
                    @RequestParam(name = "hqxq",required = true) Integer hqxq,
                    @RequestParam(name = "rzzz",required = true) Integer rzzz,
                    @RequestParam(name = "bpkn",required = true) Integer bpkn,
                    @RequestParam(name = "tjcs",required = true) Integer tjcs,
                    @RequestParam(name = "xxcz",required = true) Integer xxcz,
                    @RequestParam(name = "fszj",required = true) Integer fszj
            )
    {
        BhyfBdbLearnCheck entiy =bhyfBdbService.findLearnCheckById(id);
        if(entiy!=null && entiy.getId()>0) {
            entiy.setBpkn(bpkn);
            entiy.setFszj(fszj);
            entiy.setHqxq(hqxq);
            entiy.setJjzd(jjzd);
            entiy.setRzzz(rzzz);
            entiy.setTjcs(tjcs);
            entiy.setXxcz(xxcz);
            bhyfBdbService.updateLearncheck(entiy);
        }
        return ResultBody.ok().data(entiy);
    }

    /**
     * 批量添加观察记录详细清单
     * @param observid
     * @param details
     * @return
     */
    @ApiOperation(value = "批量添加观察记录详细清单", notes = "批量添加观察记录详细清单")
    @PostMapping("/bdb/addobservdetails")
    public ResultBody<List<BhyfBdbObservDetail>> addBhyfBdbObservDetail(
            @RequestParam(name = "observid",required = true) Integer observid,
            @RequestParam(name = "details",required = true) String details
    )
    {
        int d = bhyfBdbService.deleteBhyfBdbObservDetailByObservId(observid);
        List<BhyfBdbObservDetail> inlist = JSONArray.parseArray(details, BhyfBdbObservDetail.class);
        if(inlist!=null) {
            for (BhyfBdbObservDetail entiy : inlist) {
                entiy.setObservrecordid(observid);
                entiy.setCreatetime(new Date());
                entiy.setUpdatetime(new Date());
                bhyfBdbService.addBhyfBdbObservDetail(entiy);
            }
        }
        List<BhyfBdbObservDetail> list = bhyfBdbService.getBhyfBdbObservDetailByObservId(observid);
        return ResultBody.ok().data(list);
    }

    /**
     * 获取观察记录的详细清单
     * @param observid
     * @return
     */
    @ApiOperation(value = "获取观察记录的详细清单", notes = "获取观察记录的详细清单")
    @GetMapping("/bdb/getobservdetails")
    public ResultBody<List<BhyfBdbObservDetail>> getBhyfBdbObservDetailByObservId(
            @RequestParam(name = "observid",required = true) Integer observid
    )
    {
        List<BhyfBdbObservDetail> list = bhyfBdbService.getBhyfBdbObservDetailByObservId(observid);
        return ResultBody.ok().data(list);
    }

    /**
     * 获取教育计划列表
     * @param map
     * @return
     */
    @ApiOperation(value = "获取教育计划列表", notes = "获取教育计划列表")
    @GetMapping("/bdb/eduprojectlist")
    public ResultBody<List<BhyfBdbEduProject>> getBhyfBdbEduProjectList(
            @RequestParam(required = false) Map map
    )
    {
        return ResultBody.ok().data(bhyfBdbService.findBhyfBdbEduProjectList(new PageParams(map)));
    }

    @ApiOperation(value = "更新教育计划", notes = "更新教育计划")
    @PostMapping("/bdb/updateeduproject")
    public ResultBody<BhyfBdbLearnCheck> updateBhyfBdbEduProject
            (
                    @RequestParam(name = "id",required = true) Integer id,
                    @RequestParam(name = "status",required = true) Integer status
            )
    {
        BhyfBdbEduProject entiy =bhyfBdbService.findBhyfBdbEduProjectById(id);
        if(entiy!=null && entiy.getId()>0) {
            entiy.setStatus(status);
            bhyfBdbService.updateBhyfBdbEduProject(entiy);
        }
        return ResultBody.ok().data(entiy);
    }

    @ApiOperation(value = "新增教育计划", notes = "新增教育计划")
    @PostMapping("/bdb/addeduproject")
    public ResultBody<BhyfBdbEduProject> addBhyfBdbEduProject
            (
                    @RequestParam(name = "classid",required = true) Integer classid,
                    @RequestParam(name = "type",required = true) Integer type,
                    @RequestParam(name = "chosedate",required = true) String chosedate,
                    @RequestParam(name = "rulename",required = true) String rulename,
                    @RequestParam(name = "rulelevel",required = true) Integer rulelevel,
                    @RequestParam(name = "learnname",required = true) String  learnname,
                    @RequestParam(name = "learnlevel",required = true) Integer learnlevel,
                    @RequestParam(name = "students",required = true) String students,
                    @RequestParam(name = "uprules",required = true) String uprules,
                    @RequestParam(name = "uplearns",required = true) String uplearns,
                    @RequestParam(name = "angles",required = true) String angles,
                    @RequestParam(name = "goods",required = true) String goods,
                    @RequestParam(name = "teachers",required = true) String teachers,
                    @RequestParam(name = "status",required = true) Integer status,
                    @RequestParam(name = "operid",required = true) Integer operid,
                    @RequestParam(name = "opername",required = true) String opername,
                    @RequestParam(name = "others",required = true) String others,
                    @RequestParam(name = "currents",required = true) String currents,
                    @RequestParam(name = "datas",required = true) String datas,
                    @RequestParam(name = "gid",required = true) Integer gid,
                    @RequestParam(name = "gname",required = false) String gname
            )
    {
            BhyfBdbEduProject model = new BhyfBdbEduProject();
            model.setType(type);
            model.setStatus(status);
            model.setAngles(angles);
            model.setClassid(classid);
            model.setChosedate(chosedate);
            model.setCreatetime(new Date());
            model.setGoods(goods);
            model.setLearnlevel(learnlevel);
            model.setUpdatetime(new Date());
            model.setLearnname(learnname);
            model.setOperid(operid);
            model.setOpername(opername);
            model.setOthers(others);
            model.setRulename(rulename);
            model.setRulelevel(rulelevel);
            model.setStudents(students);
            model.setTeachers(teachers);
            model.setUplearns(uplearns);
            model.setUprules(uprules);
            model.setCurrents(currents);
            model.setDatas(datas);
            model.setGid(gid);
            model.setGname(gname);
            model = bhyfBdbService.addBhyfBdbEduProject(model);
            return ResultBody.ok().data(model);
    }

    /**
     * 新增树莓派信息
     * @param mac
     * @param localip
     * @param devicesecret
     * @param productkey
     * @param devicename
     * @param s_ver
     * @param h_ver
     * @param vnc_port
     * @param ssh_port
     * @return
     */
    @ApiOperation(value = "新增树莓派信息", notes = "新增树莓派信息")
    @PostMapping("/bdb/addraspiinfo")
    public ResultBody<BhyfBflRaspiInfo> addBhyfBflRaspiInfo
            (
                    @RequestParam(name = "mac",required = true) String mac,
                    @RequestParam(name = "localip",required = true) String localip,
                    @RequestParam(name = "devicesecret",required = true) String devicesecret,
                    @RequestParam(name = "productkey",required = true) String productkey,
                    @RequestParam(name = "devicename",required = true) String  devicename,
                    @RequestParam(name = "s_ver",required = true) String  s_ver,
                    @RequestParam(name = "h_ver",required = true) String  h_ver,
                    @RequestParam(name = "vnc_port",required = true) Integer  vnc_port,
                    @RequestParam(name = "ssh_port",required = true) Integer  ssh_port
            )
    {
        BhyfBflRaspiInfo entiy = new BhyfBflRaspiInfo();
        entiy.setDevicename(devicename);
        entiy.setDevicesecret(devicesecret);
        entiy.setLocalip(localip);
        entiy.setMac(mac);
        entiy.setProductkey(productkey);
        entiy.setsVer(s_ver);
        entiy.sethVer(h_ver);
        entiy.setVncPort(vnc_port);
        entiy.setSshPort(ssh_port);
        entiy.setCreatetime(new Date());
        entiy.setUpdatetime(new Date());
        entiy = bhyfBdbService.addBhyfBflRaspiInfo(entiy);
        return ResultBody.ok().data(entiy);
    }

    /**
     * 更新树莓派信息
     * @param id
     * @param localip
     * @param devicesecret
     * @param productkey
     * @param devicename
     * @param s_ver
     * @param h_ver
     * @param vnc_port
     * @param ssh_port
     * @return
     */
    @ApiOperation(value = "更新树莓派信息", notes = "更新树莓派信息")
    @PostMapping("/bdb/updateraspiinfo")
    public ResultBody<BhyfBflRaspiInfo> updateBhyfBflRaspiInfo
            (
                    @RequestParam(name = "id",required = true) Integer id,
                    @RequestParam(name = "localip",required = true) String localip,
                    @RequestParam(name = "devicesecret",required = true) String devicesecret,
                    @RequestParam(name = "productkey",required = true) String productkey,
                    @RequestParam(name = "devicename",required = true) String  devicename,
                    @RequestParam(name = "s_ver",required = true) String  s_ver,
                    @RequestParam(name = "h_ver",required = true) String  h_ver,
                    @RequestParam(name = "vnc_port",required = true) Integer  vnc_port,
                    @RequestParam(name = "ssh_port",required = true) Integer  ssh_port
            )
    {
        BhyfBflRaspiInfo entiy = new BhyfBflRaspiInfo();
        entiy = bhyfBdbService.getBhyfBflRaspiInfoById(id);
        if(entiy!=null) {
            entiy.setDevicename(devicename);
            entiy.setDevicesecret(devicesecret);
            entiy.setLocalip(localip);
            entiy.setProductkey(productkey);
            entiy.setsVer(s_ver);
            entiy.sethVer(h_ver);
            entiy.setVncPort(vnc_port);
            entiy.setSshPort(ssh_port);
            entiy.setUpdatetime(new Date());
            entiy = bhyfBdbService.updateBhyfBflRaspiInfo(entiy);
            return ResultBody.ok().data(entiy);
        }else{
            return ResultBody.failed().data(-1);
        }
    }

    /**
     * 更新树莓派状态
     * @param id
     * @param online_status
     * @param status
     * @return
     */
    @ApiOperation(value = "更新树莓派状态", notes = "更新树莓派状态")
    @PostMapping("/bdb/updateraspistatus")
    public ResultBody<BhyfBflRaspiInfo> updateBhyfBflRaspiStatus
            (
                    @RequestParam(name = "id",required = true) Integer id,
                    @RequestParam(name = "online_status",required = true) Integer  online_status,
                    @RequestParam(name = "status",required = true) Integer  status
            )
    {
        BhyfBflRaspiInfo entiy = new BhyfBflRaspiInfo();
        entiy = bhyfBdbService.getBhyfBflRaspiInfoById(id);
        if(entiy!=null) {
            entiy.setOnlineStatus(online_status);
            entiy.setStatus(status);
            entiy.setUpdatetime(new Date());
            entiy = bhyfBdbService.updateBhyfBflRaspiInfo(entiy);
            return ResultBody.ok().data(entiy);
        }else{
            return ResultBody.failed().data(-1);
        }
    }

    /**
     * 新增树莓派绑定
     * @param mac
     * @param cid
     * @return
     */
    @ApiOperation(value = "新增树莓派绑定", notes = "新增树莓派绑定")
    @PostMapping("/bdb/addraspibind")
    public ResultBody<BhyfBflRaspiBind> addBhyfBflRaspiBind
            (
                    @RequestParam(name = "mac",required = true) String mac,
                    @RequestParam(name = "cid",required = true) Integer cid
            )
    {
        BhyfBflRaspiBind entiy = new BhyfBflRaspiBind();
        entiy.setCid(cid);
        entiy.setMac(mac);
        entiy.setCtime(new Date());
        entiy = bhyfBdbService.addBhyfBflRaspiBind(entiy);
        return ResultBody.ok().data(entiy);
    }

    /**
     * 解除树莓派绑定
     * @param mac
     * @param cid
     * @return
     */
    @ApiOperation(value = "解除树莓派绑定", notes = "解除树莓派绑定")
    @PostMapping("/bdb/deleteraspibind")
    public ResultBody<Integer> deleteBhyfBflRaspiBind
            (
                    @RequestParam(name = "mac",required = true) String mac,
                    @RequestParam(name = "cid",required = true) Integer cid
            )
    {
        BhyfBflRaspiBind entiy = new BhyfBflRaspiBind();
        entiy.setCid(cid);
        entiy.setMac(mac);
        bhyfBdbService.deleteBhyfBflRaspiBind(entiy);
        return ResultBody.ok().data(1);
    }

    @ApiOperation(value = "获取树莓派列表", notes = "获取树莓派列表")
    @GetMapping("/bdb/bflraspilist")
    public ResultBody<List<BhyfBflRaspiInfo>> getBhyfBflRaspiList(
            @RequestParam(required = false) Map map
    )
    {
        List<BhyfBflRaspiInfo> lt = new ArrayList<>();
        lt = bhyfBdbService.findBhyfBflRaspiInfoList(new PageParams(map));
        return ResultBody.ok().data(lt);
    }

    /**
     * 获取班级绑定的树莓派列表
     * @param cid
     * @return
     */
    @ApiOperation(value = "获取班级绑定的树莓派列表", notes = "获取班级绑定的树莓派列表")
    @GetMapping("/bdb/bflraspilisbyclass")
    public ResultBody<List<BhyfBflRaspiInfo>> getBhyfBflRaspiList(
            @RequestParam(required = false) Integer cid
    )
    {
        List<BhyfBflRaspiBind> lt = new ArrayList<>();
        List<BhyfBflRaspiInfo> raspiInfos = new ArrayList<>();
        lt = bhyfBdbService.getBhyfBflRaspiBindByClassId(cid);
        for(BhyfBflRaspiBind entiy:lt){
            BhyfBflRaspiInfo raspiInfo = bhyfBdbService.getBhyfBflRaspiInfoByMac(entiy.getMac());
            raspiInfos.add(raspiInfo);
        }
        return ResultBody.ok().data(raspiInfos);
    }

    /**
     * 获取班级当天最新的环境温度数据
     * @param gid
     * @param classid
     * @return
     */
    @ApiOperation(value = "获取班级当天最新的环境温度数据", notes = "获取班级当天最新的环境温度数据")
    @GetMapping("/bdb/lastenvdatalist")
    public ResultBody<List<BhyfBdbEnvData>> getLastBhyfBdbEnvData(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid
    )
    {
        List<BhyfBdbEnvData> lt = new ArrayList<>();
        lt = bhyfBdbService.getLastBdbEnvDataByClass(gid,classid);
        return ResultBody.ok().data(lt);
    }

    /**
     * 获取班级当天的环境温度数据
     * @param gid
     * @param classid
     * @return
     */
    @ApiOperation(value = "获取班级当天的环境温度数据", notes = "获取班级当天的环境温度数据")
    @GetMapping("/bdb/envdatalist")
    public ResultBody<List<BhyfBdbEnvData>> getBhyfBdbEnvData(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid
    )
    {
        List<BhyfBdbEnvData> lt = new ArrayList<>();
        lt = bhyfBdbService.getBdbEnvDataByClass(gid,classid);
        return ResultBody.ok().data(lt);
    }

    /**
     * 新增健康码
     * @param personid
     * @param fathercode
     * @param mothercode
     * @param childcode
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "新增健康码", notes = "新增健康码")
    @PostMapping("/bdb/addhealthcode")
    public ResultBody<BhyfBdbHealthCode> addBhyfBdbHealthCode
            (
                    @RequestParam(name = "personid",required = true) Integer personid,
                    @RequestParam(name = "fathercode",required = true) String fathercode,
                    @RequestParam(name = "mothercode",required = true) String mothercode,
                    @RequestParam(name = "childcode",required = true) String childcode,
                    @RequestParam(name = "checkdate",required = true) String  checkdate
            )
    {
        BhyfBdbHealthCode entiy = new BhyfBdbHealthCode();
        entiy.setCheckdate(checkdate);
        entiy.setChildcode(childcode);
        entiy.setFathercode(fathercode);
        entiy.setMothercode(mothercode);
        entiy.setPersonid(personid);
        entiy.setCreatetime(new Date());
        entiy = bhyfBdbService.addBdbHealthCode(entiy);
        return ResultBody.ok().data(entiy);
    }

    /**
     * 新增问卷
     * @param personid
     * @param temp
     * @param questa
     * @param questb
     * @param questc
     * @param contents
     * @param name
     * @param phone
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "新增问卷", notes = "新增问卷")
    @PostMapping("/bdb/addquestion")
    public ResultBody<BhyfBdbQuestion> addBhyfBdbQuestion
            (
                    @RequestParam(name = "personid",required = true) Integer personid,
                    @RequestParam(name = "temp",required = true) Float temp,
                    @RequestParam(name = "questa",required = true) Integer questa,
                    @RequestParam(name = "questb",required = true) Integer questb,
                    @RequestParam(name = "questc",required = true) Integer questc,
                    @RequestParam(name = "contents",required = false) String contents,
                    @RequestParam(name = "name",required = false) String name,
                    @RequestParam(name = "phone",required = false) String phone,
                    @RequestParam(name = "checkdate",required = true) String  checkdate
            )
    {
        BhyfBdbQuestion entiy = new BhyfBdbQuestion();
        entiy.setCheckdate(checkdate);
        entiy.setQuesta(questa);
        entiy.setQuestb(questb);
        entiy.setQuestc(questc);
        if(name!=null)entiy.setName(name);
        if(phone!=null)entiy.setPhone(phone);
        if(contents!=null)entiy.setContents(contents);
        entiy.setTemp(temp);
        entiy.setPersonid(personid);
        entiy.setCreatetime(new Date());
        entiy = bhyfBdbService.addBhyfBdbQuestion(entiy);
        return ResultBody.ok().data(entiy);
    }

    /**
     * 新增每日表现评分
     * @param personid
     * @param scores
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "新增每日表现评分", notes = "新增每日表现评分")
    @PostMapping("/bdb/addtodayscore")
    public ResultBody<BhyfBdbTodayScore> addBhyfBdbTodayScore
            (
                    @RequestParam(name = "personid",required = true) Integer personid,
                    @RequestParam(name = "scores",required = true) String scores,
                    @RequestParam(name = "checkdate",required = true) String  checkdate
            )
    {
        BhyfBdbTodayScore entiy = new BhyfBdbTodayScore();
        entiy.setCheckdate(checkdate);
        entiy.setScores(scores);
        entiy.setPersonid(personid);
        entiy.setCreatetime(new Date());
        entiy = bhyfBdbService.addBdbTodayScore(entiy);
        return ResultBody.ok().data(entiy);
    }

    /**
     * 获取学生指定日期的温度数据
     * @param mac
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "获取学生指定日期的温度数据", notes = "获取学生指定日期的温度数据")
    @GetMapping("/bdb/templist")
    public ResultBody<List<BhyfBdbTemp>> getBdbTempByPerson(
            @RequestParam(required = true) String mac,
            @RequestParam(required = true) String checkdate
    )
    {
        List<BhyfBdbTemp> lt = new ArrayList<>();
        lt = bhyfBdbService.getBdbTempByPerson(mac,checkdate);
        return ResultBody.ok().data(lt);
    }

    /**
     * 获取学生指定日期的问卷数据
     * @param personid
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "获取学生指定日期的问卷数据", notes = "获取学生指定日期的问卷数据")
    @GetMapping("/bdb/questionlist")
    public ResultBody<List<BhyfBdbQuestion>> getBhyfBdbQuestionByPerson(
            @RequestParam(required = true) Integer personid,
            @RequestParam(required = true) String checkdate
    )
    {
        List<BhyfBdbQuestion> lt = new ArrayList<>();
        lt = bhyfBdbService.getBhyfBdbQuestionByPerson(personid,checkdate);
        return ResultBody.ok().data(lt);
    }

    /**
     * 获取学生指定日期的健康码数据
     * @param personid
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "获取学生指定日期的健康码数据", notes = "获取学生指定日期的健康码数据")
    @GetMapping("/bdb/healthcodelist")
    public ResultBody<List<BhyfBdbHealthCode>> getBhyfBdbHealthCodeByPerson(
            @RequestParam(required = true) Integer personid,
            @RequestParam(required = true) String checkdate
    )
    {
        List<BhyfBdbHealthCode> lt = new ArrayList<>();
        lt = bhyfBdbService.getBhyfBdbHealthCodeByPerson(personid,checkdate);
        return ResultBody.ok().data(lt);
    }

    /**
     * 获取学生指定日期的每日评分
     * @param personid
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "获取学生指定日期的每日评分", notes = "获取学生指定日期的每日评分")
    @GetMapping("/bdb/todayscorelist")
    public ResultBody<List<BhyfBdbTodayScore>> getBdbTodayScoreByPerson(
            @RequestParam(required = true) Integer personid,
            @RequestParam(required = true) String checkdate
    )
    {
        List<BhyfBdbTodayScore> lt = new ArrayList<>();
        lt = bhyfBdbService.getBdbTodayScoreByPerson(personid,checkdate);
        return ResultBody.ok().data(lt);
    }

    /**
     * 获取学生指定日期的报警温度
     * @param mac
     * @param checkdate
     * @return
     */
    @ApiOperation(value = "获取学生指定日期的报警温度", notes = "获取学生指定日期的报警温度")
    @GetMapping("/bdb/warningtemplist")
    public ResultBody<List<BhyfBdbWarningTemp>> getBdbWarningTempByPerson(
            @RequestParam(required = true) String mac,
            @RequestParam(required = true) String checkdate
    )
    {
        List<BhyfBdbWarningTemp> lt = new ArrayList<>();
        lt = bhyfBdbService.getBdbWarningTempByPerson(mac,checkdate);
        return ResultBody.ok().data(lt);
    }

    /**
     * 获取园所食谱
     * @param gid
     * @param starttime
     * @param endtime
     * @return
     */
    @ApiOperation(value = "获取园所食谱", notes = "获取园所食谱")
    @GetMapping("/bdb/recipelist")
    public ResultBody<List<BhyfBdbRecipe>> getBdbRecipeList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbRecipe> lt = new ArrayList<>();
        lt = bhyfBdbService.getBdbRecipeList(gid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取睡眠数据（新-测试展示）", notes = "获取睡眠数据（新-测试展示）")
    @GetMapping("/bdb/sleeplistshow")
    public ResultBody<List<BhyfBdbSleepPerson>> getBhyfBdbSleepPersonList(
            @RequestParam(required = true) String mac,
            @RequestParam(required = true) String sleepdate
    )
    {
        List<BhyfBdbSleepPerson> lt = bhyfBdbService.getBhyfBdbSleepPersonList(mac,sleepdate);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取运动数据（新-测试展示）", notes = "获取运动数据（新-测试展示）")
    @GetMapping("/bdb/sportlistshow")
    public ResultBody<List<BhyfBdbSportPerson>> getBhyfBdbSportPersonList(
            @RequestParam(required = true) String mac,
            @RequestParam(required = true) String sportdate
    )
    {
        List<BhyfBdbSportPerson> lt = bhyfBdbService.getBhyfBdbSportPersonList(mac,sportdate);
        return ResultBody.ok().data(lt);
    }


    @ApiOperation(value = "获取新的二级基站列表", notes = "获取新的二级基站列表")
    @GetMapping("/bdb/basestationlist")
    public ResultBody<List<BhyfBdbBaseStation>> getBhyfBdbBaseStationList(
            @RequestParam(required = false) String mac,
            @RequestParam(required = false) Integer gid,
            @RequestParam(required = false) Integer classid
    )
    {
        List<BhyfBdbBaseStation> lt = bhyfBdbService.getBhyfBdbBaseStationList(gid,classid,mac);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "解除二级基站绑定", notes = "解除二级基站绑定")
    @GetMapping("/bdb/disbindbasestation")
    public ResultBody<Integer> disBindBhyfBdbBaseStation(
            @RequestParam(required = true) String mac
    )
    {
        if(mac!="") {
            Integer lt = bhyfBdbService.deleteBhyfBdbBaseStation(mac);
            return ResultBody.ok().data(lt);
        }else{
            return ResultBody.failed();
        }
    }

    @ApiOperation(value = "新增二级基站绑定", notes = "新增二级基站绑定")
    @PostMapping("/bdb/addbindbasestation")
    public ResultBody<BhyfBdbBaseStation> addBhyfBdbBaseStation
            (
                    @RequestParam(name = "classid",required = true) Integer classid,
                    @RequestParam(name = "gid",required = true) Integer gid,
                    @RequestParam(name = "mac",required = true) String  mac,
                    @RequestParam(name = "classname",required = false) String  classname,
                    @RequestParam(name = "version",required = false) String  version,
                    @RequestParam(name = "basetype",required = false) String  basetype,
                    @RequestParam(name = "isspecial",required = false) Integer  isspecial
            )
    {
        BhyfBdbBaseStation entiy = new BhyfBdbBaseStation();
        entiy.setClassid(classid);
        entiy.setGid(gid);
        entiy.setMac(mac);
        entiy.setClassname(classname);
        entiy.setCreatetime(new Date());
        if(version!=null)entiy.setVersion(version);
        if(basetype!=null)entiy.setBasetype(basetype);
        if(isspecial!=null)entiy.setIsspecified(isspecial);
        entiy = bhyfBdbService.addBhyfBdbBaseStation(entiy);
        return ResultBody.ok().data(entiy);
    }


    @ApiOperation(value = "获取学生时间段内每天最后的温度数据", notes = "获取学生时间段内每天最后的温度数据")
    @GetMapping("/bdb/lasttemplist")
    public ResultBody<List<BhyfBdbTemp>> getLastTempListByMac(
            @RequestParam(required = true) String mac,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime,
            @RequestParam(required = false) Integer isPreCheck
    )
    {
        List<BhyfBdbTemp> lt = new ArrayList<>();
        starttime = DateUtil.parse(starttime,"yyyy-MM-dd 00:00:01").toString();
        if(isPreCheck == null)isPreCheck=0;
        if(isPreCheck==1){
            endtime = DateUtil.parse(endtime,"yyyy-MM-dd 00:08:00").toString();
        }else{
            endtime = DateUtil.parse(endtime,"yyyy-MM-dd HH:mm:ss").toString();
        }
        lt = bhyfBdbService.getLastTempListByMac(mac,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取班级的问卷数据", notes = "获取班级的问卷数据")
    @GetMapping("/bdb/questionlistbyclass")
    public ResultBody<List<BhyfBdbQuestion>> getBhyfBdbQuestionByClass(
            @RequestParam(required = false) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String checkdate,
            @RequestParam(required = false) Integer gradenum
    )
    {
        List<BhyfBdbQuestion> lt = new ArrayList<>();
        if(gradenum==null)gradenum=0;
        lt = bhyfBdbService.getBhyfBdbQuestionByClass(gid,gradenum,classid,checkdate);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取班级的二维码数据", notes = "获取班级的二维码数据")
    @GetMapping("/bdb/healthcodelistbyclass")
    public ResultBody<List<BhyfBdbHealthCode>> getBhyfBdbHealthCodeByClass(
            @RequestParam(required = false) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String checkdate
    )
    {
        List<BhyfBdbHealthCode> lt = new ArrayList<>();
        lt = bhyfBdbService.getBhyfBdbHealthCodeByClass(gid,classid,checkdate);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取关注列表", notes = "获取关注列表")
    @GetMapping("/bdb/tracklist")
    public ResultBody<List<BhyfBdbTrack>> getBhyfBdbTrackList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String trackdate,
            @RequestParam(required = true) Integer tracktype
    )
    {
        List<BhyfBdbTrack> lt = new ArrayList<>();
        lt = bhyfBdbService.getBhyfBdbTrackList(gid,classid,tracktype,trackdate);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "新增关注追踪", notes = "新增关注追踪")
    @PostMapping("/bdb/addtrack")
    public ResultBody<BhyfBdbTrack> addBhyfBdbTrack
            (
                    @RequestParam(name = "gid",required = true) Integer gid,
                    @RequestParam(name = "classid",required = true) Integer classid,
                    @RequestParam(name = "personid",required = true) Integer  personid,
                    @RequestParam(name = "name",required = true) String  name,
                    @RequestParam(name = "trackdate",required = true) String  trackdate,
                    @RequestParam(name = "tracktype",required = true) Integer  tracktype,
                    @RequestParam(name = "logo",required = false) String  logo,
                    @RequestParam(name = "temp",required = false) Float  temp,
                    @RequestParam(name = "temptime",required = false) String  temptime,
                    @RequestParam(name = "reason",required = false) String  reason,
                    @RequestParam(name = "leaveid",required = false) Integer  leaveid
            )
    {
        BhyfBdbTrack entiy = new BhyfBdbTrack();
        entiy.setGid(gid);
        entiy.setClassid(classid);
        entiy.setPersonid(personid);
        entiy.setName(name);
        entiy.setTrackdate(trackdate);
        entiy.setTracktype(tracktype);
        if(logo!=null)entiy.setLogo(logo);
        if(temp!=null)entiy.setTemp(temp);
        if(temptime!=null)entiy.setTemptime(temptime);
        if(reason!=null)entiy.setReason(reason);
        if(leaveid!=null)entiy.setLeaveid(leaveid);
        entiy = bhyfBdbService.addBhyfBdbTrack(entiy);
        return ResultBody.ok().data(entiy);
    }

    @ApiOperation(value = "获取班级时间段内每个手环的最后的温度数据", notes = "获取班级时间段内每个手环的最后的温度数据")
    @GetMapping("/bdb/lasttemplistbyclass")
    public ResultBody<List<BhyfBdbTemp>> getLastTempListByClass(
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbTemp> lt = new ArrayList<>();
        if(classid>0) {
            lt = bhyfBdbService.getLastTempListByClass(classid, starttime, endtime);
        }
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取班级时间段内每个手环的预测温数据", notes = "获取班级时间段内每个手环的预测温数据")
    @GetMapping("/bdb/lastpretemplistbyclass")
    public ResultBody<List<BhyfBdbPreTemp>> getLastPreTempListByClass(
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbPreTemp> lt = new ArrayList<>();
        if(classid>0){
            lt = bhyfBdbService.getLastPreTempListByClass(classid,starttime,endtime);
        }
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "新增预测温", notes = "新增预测温")
    @PostMapping("/bdb/addpretemp")
    public ResultBody<BhyfBdbPreTemp> addBhyfBdbPreTemp
            (
                    @RequestParam(name = "mac",required = true) String  mac,
                    @RequestParam(name = "temp",required = true) Float  temp,
                    @RequestParam(name = "checktime",required = true) String  checktime
            )
    {
        BhyfBdbPreTemp entiy = new BhyfBdbPreTemp();
        if(temp!=null)entiy.setTemp(temp);
        if(checktime!=null)entiy.setChecktime(checktime);
        if(mac!=null)entiy.setMac(mac);
        entiy.setCreatetime(new Date());
        entiy = bhyfBdbService.addBhyfBdbPreTemp(entiy);
        return ResultBody.ok().data(entiy);
    }

    @ApiOperation(value = "获取学生时间段内最后的预测温数据", notes = "获取学生时间段内最后的预测温数据")
    @GetMapping("/bdb/lastpretemplist")
    public ResultBody<List<BhyfBdbPreTemp>> getLastPreTempListByMac(
            @RequestParam(required = true) String mac,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbPreTemp> lt = new ArrayList<>();
        lt = bhyfBdbService.getLastPreTempListByMac(mac,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取班级时间段内报警的人和温度", notes = "获取班级时间段内报警的人和温度")
    @GetMapping("/bdb/warningtemplistbyclass")
    public ResultBody<List<BhyfBdbWarningTemp>> getBdbWarningTempByClass(
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbWarningTemp> lt = new ArrayList<>();
        if(classid>0) {
            lt = bhyfBdbService.getBdbWarningTempByClass(classid, starttime, endtime);
        }
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "新增手动测温", notes = "新增手动测温")
    @PostMapping("/bdb/addwarningtemp")
    public ResultBody<BhyfBdbWarningTemp> addBhyfBdbWarningTemp
            (
                    @RequestParam(name = "mac",required = true) String  mac,
                    @RequestParam(name = "temp",required = true) Float  temp,
                    @RequestParam(name = "checktype",required = true) Integer  checktype,
                    @RequestParam(name = "checktime",required = true) String  checktime
            )
    {
        BhyfBdbWarningTemp entiy = new BhyfBdbWarningTemp();
        if(temp!=null)entiy.setTemp(temp);
        if(checktime!=null)entiy.setChecktime(checktime);
        if(mac!=null)entiy.setMac(mac);
        if(checktype!=null)entiy.setChecktype(checktype);
        entiy.setCreatetime(new Date());
        entiy = bhyfBdbService.addBhyfBdbWarningTemp(entiy);
        return ResultBody.ok().data(entiy);
    }

    @ApiOperation(value = "班级统计人数-测温", notes = "班级统计人数-测温")
    @GetMapping("/bdb/classtempcount")
    public ResultBody<List<BhyfBdbClassCount>> getTempCheckCountByClass(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer temptype,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbClassCount> lt = new ArrayList<>();
        if(temptype==1) {
            lt = bhyfBdbService.getPreTempCheckCountByClass(gid, starttime, endtime);
        }
        if(temptype==2) {
            lt = bhyfBdbService.getTempCheckCountByClass(gid, starttime, endtime);
        }
        if(temptype==3) {
            lt = bhyfBdbService.getWarnTempCheckCountByClass(gid, starttime, endtime);
        }
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "班级统计人数-关注", notes = "班级统计人数-关注")
    @GetMapping("/bdb/trackcount")
    public ResultBody<List<BhyfBdbClassCount>> getTrackCheckCountByClass(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer tracktype,
            @RequestParam(required = true) String checkdate
    )
    {
        List<BhyfBdbClassCount> lt = new ArrayList<>();
        lt = bhyfBdbService.getTrackCountByClass(gid,tracktype,checkdate);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取测温未佩戴手环的学生", notes = "获取测温未佩戴手环的学生")
    @GetMapping("/bdb/unwearlist")
    public ResultBody<List<BhyfStudent>> getUnWearStudentList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfStudent> lt = new ArrayList<>();
        lt = bhyfBdbService.getUnWearStudentList(gid,classid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取睡眠状态不好的学生", notes = "获取睡眠状态不好的学生")
    @GetMapping("/bdb/badsleeplist")
    public ResultBody<List<BhyfBdbBadSleep>> getBadSleepStudentList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = false) Integer personid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbBadSleep> lt = new ArrayList<>();
        lt = bhyfBdbService.getBadSleepList(gid,classid,personid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取学生手环电量信息", notes = "获取学生手环电量信息")
    @GetMapping("/bdb/watchbatterylist")
    public ResultBody<List<BhyfBdbWatchBattery>> getWatchBatteryList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = false) Integer personid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbWatchBattery> lt = new ArrayList<>();
        lt = bhyfStudentService.getWatchBatteryList(gid,classid,personid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取信标电量信息", notes = "获取信标电量信息")
    @GetMapping("/bdb/beaconbatterylist")
    public ResultBody<List<BhyfBdbBeaconBattery>> getBeaconBatteryList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbBeaconBattery> lt = new ArrayList<>();
        lt = bhyfStudentService.getBeaconBatteryList(gid,classid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }


    @ApiOperation(value = "获取学生手环版本信息", notes = "获取学生手环版本信息")
    @GetMapping("/bdb/watchversionlist")
    public ResultBody<List<BhyfBdbWatchVersion>> getWatchVersionList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = false) Integer personid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbWatchVersion> lt = new ArrayList<>();
        lt = bhyfStudentService.getWatchVersionList(gid,classid,personid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "获取每日时刻内的众数温度值", notes = "获取每日时刻内的众数温度值")
    @GetMapping("/bdb/mostttemplist")
    public ResultBody<List<BhyfBdbMostTemp>> getWatchVersionList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime,
            @RequestParam(required = false) Integer isbad
    )
    {
        List<BhyfBdbMostTemp> lt = new ArrayList<>();
        if(isbad==null) isbad=1;
        lt = bhyfBdbService.getMostTempListByClass(gid,classid,starttime,endtime,isbad);
        return ResultBody.ok().data(lt);
    }


    @ApiOperation(value = "获取年级时间段内报警的人和温度", notes = "获取年级时间段内报警的人和温度")
    @GetMapping("/bdb/warningtemplistbygrade")
    public ResultBody<List<BhyfBdbWarningTemp>> getBdbWarningTempByGrade(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer gradenum,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbWarningTemp> lt = new ArrayList<>();
        lt = bhyfBdbService.getBdbWarningTempByGradenum(gid,gradenum,classid, starttime, endtime);
        return ResultBody.ok().data(lt);
    }


    @ApiOperation(value = "获取年级时间段内每个手环的测温数据", notes = "获取年级时间段内每个手环的测温数据")
    @GetMapping("/bdb/lasttemplistbygrade")
    public ResultBody<List<BhyfBdbTemp>> getLastTempListByGrade(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer gradenum,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbTemp> lt = new ArrayList<>();
        lt = bhyfBdbService.getLastTempListByGrade(gid,gradenum,classid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "修改二级基站绑定", notes = "修改二级基站绑定")
    @PostMapping("/bdb/updatebindbasestation")
    public ResultBody<BhyfBdbBaseStation> updateBhyfBdbBaseStation
            (
                    @RequestParam(name = "id",required = true) Integer id,
                    @RequestParam(name = "version",required = false) String version,
                    @RequestParam(name = "basetype",required = false) String basetype,
                    @RequestParam(name = "isspecified",required = false) Integer  isspecified
            )
    {
        BhyfBdbBaseStation entiy = bhyfBdbService.getBhyfBdbBaseStationById(id);
        if(entiy.getId()>0) {
            if(version!=null)entiy.setVersion(version);
            if(basetype!=null)entiy.setBasetype(basetype);
            if(isspecified!=null)entiy.setIsspecified(isspecified);
            entiy = bhyfBdbService.updateBhyfBdbBaseStation(entiy);
        }
        return ResultBody.ok().data(entiy);
    }

    @ApiOperation(value = "获取班级运动数据（新-测试展示）", notes = "获取班级运动数据（新-测试展示）")
    @GetMapping("/bdb/sportlistclassshow")
    public ResultBody<List<BhyfBdbSportPerson>> getBhyfBdbSportListByClass(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) Integer classid,
            @RequestParam(required = true) String sportdate
    )
    {
        List<BhyfBdbSportPerson> lt = bhyfBdbService.getSportPersonListByClass(gid,classid,sportdate);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "园所监控：获取园所信标每天最后电量", notes = "园所监控：获取园所信标每天最后电量")
    @GetMapping("/bdb/beaconbatterylastlist")
    public ResultBody<List<BhyfBdbBeaconBattery>> getBeaconBatteryLastList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbBeaconBattery> lt = new ArrayList<>();
        lt = bhyfStudentService.getBeaconBatteryLastList(gid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "园所监控：获取园所温度异常的手环", notes = "园所监控：获取园所温度异常的手环")
    @GetMapping("/bdb/badtempwatchlist")
    public ResultBody<List<BhyfBdbTemp>> getGardenBadTempWatchList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = false) Integer gradenum,
            @RequestParam(required = false) Integer classid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbTemp> lt = new ArrayList<>();
        if(gradenum==null)gradenum=0;
        if(classid==null)classid=0;
        lt = bhyfBdbService.getGardenBadTempWatchList(gid,gradenum,classid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "园所监控：获取单个手环每天最后的电量", notes = "园所监控：获取单个手环每天最后的电量")
    @GetMapping("/bdb/watchbatterylastlist")
    public ResultBody<List<BhyfBdbWatchBattery>> getWatchBatteryLastList(
            @RequestParam(required = true) String mac,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbWatchBattery> lt = new ArrayList<>();
        lt = bhyfStudentService.getWatchBatteryLastList(mac,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "园所监控：获取园所低电量的手环", notes = "园所监控：获取园所低电量的手环")
    @GetMapping("/bdb/lowbatterywatchlist")
    public ResultBody<List<BhyfBdbWatchBattery>> getGardenBadBatteryWatchList(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbWatchBattery> lt = new ArrayList<>();
        lt = bhyfStudentService.getGardenBadBatteryWatchList(gid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

    @ApiOperation(value = "园所监控：获取园所手环每日各种温度的数量", notes = "园所监控：获取园所手环每日各种温度的数量")
    @GetMapping("/bdb/daytempcount")
    public ResultBody<List<BhyfBdbDayTempCount>> getGardenDayTempCount(
            @RequestParam(required = true) Integer gid,
            @RequestParam(required = true) String starttime,
            @RequestParam(required = true) String endtime
    )
    {
        List<BhyfBdbDayTempCount> lt = new ArrayList<>();
        lt = bhyfBdbService.getGardenDayTempCount(gid,starttime,endtime);
        return ResultBody.ok().data(lt);
    }

}
